clear all;clc
addpath(genpath('.'));  %添加工具箱路径
load pix_location
pix_location([4 1],:)=pix_location([1 4],:);
pix_location([1 2],:)=pix_location([2 1],:);
pix_location([3 2],:)=pix_location([2 3],:);
% pix_location([4 3],:)=pix_location([3 4],:);
pix_location(:,[2 1])=pix_location(:,[1 2]);
xyloObj = VideoReader('./capture_video/Cmarked_5.mp4');
% xyloObj = VideoReader('./video/1.mp4');
% frame = read(xyloObj,67); % first frame only 获取第一帧
Frame_num=xyloObj.NumFrames;
% CCC=registerImages(readFrame(xyloObj),pix_location);
% imshow(CCC),title('register video frame in Y channel')
for i=1:Frame_num
    ycbcrframe = rgb2ycbcr(readFrame(xyloObj));%imshow(frame);%一次一帧
    YC_Cover=ycbcrframe(:,:,1);
    % 空域校正
    Y_Cover=registerImages(YC_Cover,pix_location);
    Y_Cover=imresize(Y_Cover,[1080 1920]);
   
    %dft 水印信号检测 
    [bitstream(i),dff(i)]=DFT_blind_detector(Y_Cover-wiener2(Y_Cover));
%     [bitstream(i),dff(i)]=DFT_blind_detector(Y_Cover);
    %dct 同步信号检测
    Intensity(i)=Detection_DCT_synchronization(Y_Cover);
    disp(['Parallel detection :',num2str(i),'frame']);
end
save Intensity Intensity
save dff dff
save bitstream bitstream
%% 秘密信息生成
% load key; rng(key);%%key为伪随机序列种子
% msg = num2str(uint8(rand(1,64)));
% msg=strrep(msg,' ','');%剔除空格